
<!--top结束-->
<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->
            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->
                <!-- contents start -->
                <div id="contents">
                    <div id="contents_container">
                        <form id='out_stock_form' action="<?= blang_url('wms/InStock/abnormal_stock') ?>" method="post" name="myform" onsubmit="return myform_submit()" autocomplete="off" >
                            <table cellpadding="0" cellspacing="0" id="table_forms" border="1">
                                <tr>
                                    <td class="forms_left">PID:</td>
                                    <td><input id="pid" type="text" name="pid" value="" />-</td>
                                </tr>
                                    <td class="forms_left"><?= lang('wms_panel_30010') ?>:</td>
                                    <td><input id="ask_staff" type="text" name="ask_staff" value=""  readOnly="true" /></td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30011') ?>:</td>
                                    <td><input id="ref_num" type="text" name="ref_num" value=""  readOnly="true"/>*</td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30002') ?>:</td>
                                    <td><textarea rows="2" cols="50" id="comments" name="comments" value=""></textarea></td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2" class="sub_padding_right">
                                        <button id="_button" type="button" onclick="stock_out()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 200px;" ><?= lang('wms_panel_30012') ?></button>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="forms_left"  colspan="2"  id="msg"></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <div id="contents">
                    <div id="ct_search" >
                        <form action="<?=blang_url('wms/Stock/outStock')?>" method="post" name="searchform" >
                            <table id="search_tb">
                                <tr>
                                    <td>
                                        &nbsp;
                                        SKU：<input size="20" name="sku" value="<?=isset($sku)?$sku:'';?>" placeholder="SKU" />
                                        PID：<input size="15" name="pid" value="<?=isset($pid)?$pid:'';?>" placeholder="PID" />
                                        <?= lang('wms_panel_30011') ?>：<input size="25" name="order_num" value="<?=isset($order_num)?$order_num:'';?>" placeholder="<?= lang('wms_panel_30011') ?>" />
                                        &nbsp;&nbsp;&nbsp;
                                        <input type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content">
                        <table class="tbwd800">
                            <tr>
                                <th><?= lang('wms_panel_30011') ?></th>
                                <th>PID</th>
<!--                                <th><?= lang('wms_panel_30048') ?></th>-->
                                <th>point</th>
                                <th><?= lang('wms_panel_30010') ?></th>
                                <th>SKU</th>
                                <th width="15%" ><?=lang('order_cz')?></th>
                            </tr>
                            <?php foreach($outList as $row){?>
                                <tr align="left" class="moves">
                                    <td><?=$row['order_num'] ;?></td>
                                    <td><?=$row['pid']?></td>
<!--                                    <td><?=$row['status_id']?></td>-->
                                    <td><?=$row['point']?></td>
                                    <td><?=$row['technician']?></td>
                                    <td><?=$row['sku']?></td>
                                    <td width="15%" align="center">
                                        <a href="<?=blang_url('products/Product_new/inDetails/'.$row['pid'])?>" style="color: <?=$rs['holdColorProduct']?>">Detail</a>
                                    </td>
                                </tr>
                            <?php }?>
                            <tr align="center">
                                <td colspan="6"><?=$pageShow?></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(window).load(function() {
        $("#pid").focus();
    }); 
    $('#pid').bind('keypress', function (event) {

        if (event.keyCode == "13") {
            if(true){
                //enter 获取配件信息
                var LDindex;
                var sku= $("#sku").val();
                var pid= $("#pid").val();
                if(pid>100){
                $.ajax({
                    type:'post',
                    timeout:60000,
                    data: {"pid":pid,"sku":sku},
                    url:"<?= blang_url('wms/InStock/get_product_part') ?>",
                    beforeSend:function(XMLHttpRequest){
                        LDindex = layer.load(1, {
                            shade: [0.1,'#fff'] //0.1透明度的白色背景
                        })
                    }, 
                    success: function (rs) {
                        layer.close(LDindex); 
                        obj=JSON.parse(rs);
                        $(".product").remove();
                        if(true==obj.success){
                            $('#ask_staff').val(obj.data.info.technician);
                            $('#ref_num').val(obj.data.info.order_num);
                            var $sku_str='';
                            var list=obj.data.list;
                            for(var i in list){
                                var row_info=list[i];
                              $sku_str+='<tr class=\"product\"><td class=\"forms_left\"><?=lang('wms_panel_30050')?>_'+(parseInt(i)+1)+'：</td><td >'
                                  +'SKU：<span  style=\"font-size:20px;color:green\">'+row_info.sku+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                                  +'<?=lang('wms_sl')?>：<span  style=\"font-size:20px;color:blue\">'+row_info.quantity+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                                  +'实际库存：<span  style=\"color:green\">'+row_info.inventory+'</span>&nbsp;&nbsp;<span  style=\"color:red\">'+row_info.msg+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                                  +'<?=lang('wms_panel_30016')?>：'+row_info.whs_code+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                                  +'<?=lang('wms_panel_30001')?>：'+row_info.type+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                                  +'</td></tr>';
                                   
                            }
                            $("#table_forms tr:eq(0)").after($sku_str)
                            $("#_button").focus();
                        }
                        else{
                            alert(obj.msg);
                            $(".product").remove();
                            $('#pid').val("");
                            $('#ask_staff').val("");
                            $('#ref_num').val("");
                            $('#ask_staff').val("");
                            $("#pid").focus();
                        }
                    },
                    error: function (e, jqxhr, settings, exception) {

                    },
                    complete : function(XMLHttpRequest,status){
                        layer.close(LDindex); 
                        if(status=='timeout'){
                            alert("Request timed out,Please try again!");
                        }
                    }
                });
                }else{
                            alert("<?=lang('wms_tips_20026')?>");
                }
            }else{
                $("#quantity").focus();
            }
        }
    });
    
    function stock_out(){
        //loading层
        var LDindex;
        var dataParam = $("#out_stock_form").serializeArray();
        var ref_num= $("#ref_num").val();
        if(ref_num==''){
            alert("<?=lang('wms_tips_20026')?>");
            return false;
        }
        $.ajax({
            type:'post',
            timeout:60000,
            data: dataParam,
            url:"<?= blang_url('wms/InStock/pid_out') ?>",
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (rs) {
                layer.close(LDindex); 
                obj=JSON.parse(rs);
                if(true==obj.success){
                            $(".product").remove();
                            $('#pid').val("");
                            $('#ask_staff').val("");
                            $('#ref_num').val("");
                            $('#ask_staff').val("");
                            $("#pid").focus();
                    $("#msg").html('Success!'+obj.msg);
                }
                else{
                    alert(obj.msg);
                    $("#sku").focus();
                }
            },
            error: function (e, jqxhr, settings, exception) {

            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("Request timed out,Please try again!");
                }
            }
        });
    }
</script>
